package math2;

import inf.jlinalg.IMatrix;
import fem2.EASMode;

/**
 * Enhanced assumed strain mode Q1/E5, designed specifically for linear
 * quadrilateral element.
 * 
 * @author hbui
 * 
 */
public class EASQ1E5 extends EASMode {

	@Override
	public int countEnhancedStrainModes() {
		return 5;
	}

	@Override
	public int countRecoverStressModes() {
		return 5;
	}

	@Override
	public void computeEASInterpolationMatrix(IMatrix g, double... xi) {
		g.set(0, 0, xi[0]);
		g.set(1, 1, xi[1]);
		g.set(2, 2, xi[0]);
		g.set(2, 3, xi[1]);
		g.set(0, 4, xi[0] * xi[1]);
		g.set(1, 4, -xi[0] * xi[1]);
		g.set(2, 4, xi[0] * xi[0] - xi[1] * xi[1]);
	}

	@Override
	public void computeRecoverStressInterpolationMatrix(IMatrix g, double... xi) {
		g.set(0, 0, 1.0);
		g.set(1, 1, 1.0);
		g.set(2, 2, 1.0);
		g.set(0, 3, xi[1]);
		g.set(1, 4, xi[0]);
	}
}
